/**
 * Created by LuBangTao on 2017/3/28.
 */
var earth = function (canvas, scene) {
    for (var i = 0; i < scene.meshes.length; i++) {
        if (scene.meshes[i].id.indexOf("earth") >= 0) {
            scene.meshes[i].dispose();
        }
    }
    var earth = new BABYLON.Mesh.CreateSphere("earth", 12, 20, scene);
    earth.position.x = 10;
    earth.position.y = 10;
    earth.position.z = 10;
    var earthMaterial = new BABYLON.StandardMaterial("material", scene);
    earthMaterial.diffuseTexture = new BABYLON.Texture("./texture/earth.jpg", scene);
    earthMaterial.backFaceCulling = false;
    earth.material = earthMaterial;
    earth.rotation.x = Math.PI;
    var positions = earth.getVerticesData(BABYLON.VertexBuffer.PositionKind);
    console.log(positions.length)
    var timer = 0;
    var isDone = false;
    var uvs = earth.getVerticesData(BABYLON.VertexBuffer.UVKind);
    // Lighting.doPositionAnimationFunc(config,scene);
    console.log(uvs.length)
    scene.registerBeforeRender(function () {
        timer += .001;
        earth.rotation.y = timer * 20;
        if (!isDone) {
            earth.scaling = new BABYLON.Vector3(Math.sin(Math.PI * timer), Math.sin(Math.PI * timer), Math.sin(Math.PI * timer));
            if (timer >= 0.451 && timer <= 0.455) {
                isDone = !isDone;
            }
        }

    })
};